import 'package:plugin_asr/entity/flow_tts_entity.dart';
import 'package:plugin_platform_interface/plugin_platform_interface.dart';

import 'entity/init_entity.dart';
import 'plugin_asr_method_channel.dart';

abstract class PluginAsrPlatform extends PlatformInterface {
  /// Constructs a PluginAsrPlatform.
  PluginAsrPlatform() : super(token: _token);

  static final Object _token = Object();

  static PluginAsrPlatform _instance = MethodChannelPluginAsr();

  /// The default instance of [PluginAsrPlatform] to use.
  ///
  /// Defaults to [MethodChannelPluginAsr].
  static PluginAsrPlatform get instance => _instance;

  /// Platform-specific implementations should set this with their own
  /// platform-specific class that extends [PluginAsrPlatform] when
  /// they register themselves.
  static set instance(PluginAsrPlatform instance) {
    PlatformInterface.verifyToken(instance, _token);
    _instance = instance;
  }

  /// 初始化 ASR SDK。
  /// @param appId 讯飞开放平台应用ID
  /// @param apiKey 讯飞开放平台API Key
  /// @param apiSecret 讯飞开放平台API Secret
  /// @return 初始化结果，0表示成功，非0表示失败
  Future<int?> init(InitEntity initEntity) {
    throw UnimplementedError('init() has not been implemented.');
  }

  /// 启动语音识别监听，返回结果。
  /// @return 识别结果字符串
  Future<String?> startAsrListener(String language) {
    throw UnimplementedError('startAsrListener() has not been implemented.');
  }

  /// 停止语音识别监听。
  Future<int?> stopAsrListener() {
    throw UnimplementedError('stopAsrListener() has not been implemented.');
  }

  /// 开始在线语音合成。
  /// @param text 需要合成的文本
  /// @return 合成结果，0表示成功，非0表示失败
  Future<int?> startOnlineTTS(String text) {
    throw UnimplementedError('startOnlineTTS() has not been implemented.');
  }

  /// 结束在线语音合成。
  /// @return 合成结果，0表示成功，非0表示失败
  Future<int?> stopOnlineTTS() {
    throw UnimplementedError('stopOnlineTTS() has not been implemented.');
  }

  /// 开始拟人语音合成。
  /// @param text 需要合成的文本
  /// @return 合成结果，0表示播放完成成功，非0表示失败
  Future<int?> startPersonTTS(String text) {
    throw UnimplementedError('startPersonTTS() has not been implemented.');
  }

  /// 开始流式拟人语音合成。
  /// @param FlowTtsEntity
  /// @return 合成结果，0表示成功，当FlowTtsEntity.status = 2时，会等到语音播放完成才返回
  Future<int?> startFlowPersonTTS(FlowTtsEntity flowTtsEntity) {
    throw UnimplementedError('startFlowPersonTTS() has not been implemented.');
  }

  /// 结束拟人语音合成。
  /// @return 合成结果，0表示成功，非0表示失败
  Future<int?> stopPersonTTS() {
    throw UnimplementedError('stopPersonTTS() has not been implemented.');
  }


  /// 设置原生端消息监听。
  Future<void> setupNativeMessageListener(Function onEvent) {
    throw UnimplementedError('setupNativeMessageListener() has not been implemented.');
  }

  Future<String?> getPlatformVersion() {
    throw UnimplementedError('getPlatformVersion() has not been implemented.');
  }
}
